# _*_ coding: utf-8 _*_
from odoo import models, fields, api


class BomLine(models.Model):
    _inherit = "mrp.bom.line"

    @api.multi
    def action_view_bom_line_product_subt(self):
        self.ensure_one()
        line = self
        action = self.env.ref("tuntex_DIS047_bom_product_substitution.bom_product_substitution_action")
        if not action:
            return True

        action_dict = action.read()[0]

        domain = [('bom_line_id', "=", line.id)]
        action_dict["domain"] = domain
        action_dict["context"] = {
            "default_bom_line_id": line.id,
            "default_subt_product_qty": line.product_qty
        }

        return action_dict
